package com.sigmazero13.gameutils;

import java.util.List;

import android.os.Bundle;
import android.util.Log;

import com.sigmazero13.gameutils.RenameDialog.OnRenameListener;

public class TeamList extends RenamableInfoList {

	Integer gameId = 0;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		Bundle bundle = getIntent().getExtras();
		gameId = bundle.getInt("game_id", 0);
		
		super.onCreate(savedInstanceState);
		
		Log.i("TeamList", "gameId is " + gameId);
	}

	@Override
	protected String getDialogTitle() {
		return getString(R.string.rename_dialog_title_team);
	}

	@Override
	protected OnRenameListener getDialogRenameListener() {
		return new OnRenameListener() {
			@Override
			public void onRename(String origName, String newName) {
				((BoardGameUtilsApp)TeamList.this.getApplication()).getDbHelper().renameTeamForGame(origName, newName, gameId);
				updateList();
			}
		};
	}

	@Override
	protected List<String> getList() {
		return ((BoardGameUtilsApp)TeamList.this.getApplication()).getDbHelper().getTeamsForGame(gameId);
	}
}
